package io.dcloud.h527baaa6.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.google.gson.Gson;

import io.dcloud.h527baaa6.bean.XmlBean;

/**
 * Created by hunanqi on 2018/3/26 0026.
 */

public class SharePreUtils {
    public static void saveData(XmlBean bean, Context context){
        Gson gson=new Gson();
        String s = gson.toJson(bean);
        SharedPreferences sharedPreferences=context.getSharedPreferences("sql",Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("json",s);
        edit.commit();
    }
    public static XmlBean getData(Context context){
        SharedPreferences sql = context.getSharedPreferences("sql", Context.MODE_PRIVATE);
        String json = sql.getString("json", "");
        Gson gson=new Gson();
       return gson.fromJson(json,XmlBean.class);
    }
}
